#ifndef HPFCONFIG_H
#define HPFCONFIG_H

#include "filterconfig.h"
#include "dmenum.h"


namespace HpfConfig {

// 滤波器参数
struct FilterParam
{
    Slope slope;                        // 倍频程斜率
    // double scale;                       // 频率缩放系数（Bessel专用，其他为1.0）
    std::array<double, 4> f;            // 调整频率
    std::array<double, 4> q;            // 4个滤波器节的Q值（最大48dB=4个二阶节）
};

struct Hpfilter
{
    PfType type;                        // 滤波器类型
    std::array<FilterParam, 7> param;
};

constexpr std::array<FilterParam, 7> HPF_BESSEL = {{
    {Slope::Oct_12dB, {1.2736, 1, 1, 1}, {0.5773, 0.0, 0.0, 0.0}},
    {Slope::Oct_24dB, {1.4192, 1.5912, 1, 1}, {0.5219, 0.8055, 0.0, 0.0}},
    {Slope::Oct_36dB, {1.6060, 1.6913, 1.9071, 1}, {0.5103, 0.6112, 1.0234, 0.0}},
    {Slope::Oct_48dB, {1.7837, 2.1953, 1.9591, 1.8376}, {0.5060, 1.2258, 0.7109, 0.5596}}
}};

constexpr std::array<FilterParam, 7> HPF_BUTTER_WORTH = {{
    {Slope::Oct_12dB, {1, 1, 1, 1}, {0.70422535, 0.0, 0.0, 0.0}},
    {Slope::Oct_24dB, {1, 1, 1, 1}, {0.92592593, 0.38167939, 0.0, 0.0}},
    {Slope::Oct_36dB, {1, 1, 1, 1}, {0.96153846, 0.70422535211, 0.2590673575, 0.0}},
    {Slope::Oct_48dB, {1, 1, 1, 1}, {0.98039126, 0.83333333, 0.55555556, 0.1953125}}
}};

constexpr std::array<FilterParam, 7> HPF_LINKWITZ_RILEY = {{
    {Slope::Oct_12dB, {1, 1, 1, 1}, {1.0, 0.0, 0.0, 0.0}},
    {Slope::Oct_24dB, {1, 1, 1, 1}, {0.70422535211, 0.70422535211, 0.0, 0.0}},
    {Slope::Oct_36dB, {1, 1, 1, 1}, {1.0, 0.5, 0.5, 0.0}},
    {Slope::Oct_48dB, {1, 1, 1, 1}, {0.92592592593, 0.3731343150, 0.92592592593, 0.3731343150}}
}};

constexpr std::array<Hpfilter, 3> FILTER = {{
    {PfType::Bessel, HPF_BESSEL},
    {PfType::ButterWorth, HPF_BUTTER_WORTH},
    {PfType::LinkwitzRiley, HPF_LINKWITZ_RILEY}
}};

BiquadCoeffs calculateCoeffs(double cutoffFreq, PfType type, Slope slope);


}


#endif // HPFCONFIG_H
